package cn.kgc.ffzw.day15.src.main.java.com.ffzw.ffzw;

public class ClassRoom {

    String[]names=new String[10];

    public void AddNames(){
        for (int i = 0; i <names.length; i++) {
            names[i]="学员"+(i+1);
        }

    }
    public String show(){
        String str="[";

        for (int i = 0; i < names.length-1; i++) {
            str+=names[i]+",";
        }
        str+=names[names.length-1]+"]";

        return str;
    }

    public boolean search(String name,int start,int end){
        if (start<=0||start>end||end>names.length){
            System.out.println("输入错误");
            return  false;
        }
        for (int i=start-1;i<end;i++){
            if (name.equals(names[i])){
                System.out.println("找到了");
                return true;
            }else {
                System.out.println("没找到");
                break;
            }

        }
        return  false;
    }

}
